package com.hongyue.shiJian;

import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Scanner;

public class Demo {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入您的生日(1990-01-01 00:00:00)");
        LocalDateTime now = LocalDateTime.now();
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String a = sc.nextLine();
        LocalDateTime pa = LocalDateTime.parse(a, df);
        Duration be = Duration.between(pa, now);
        long l = be.toHours();
        if (l >= 1) {
            System.out.println("您从出生开始到现在经历了" + l + "小时");
        } else {
            System.out.println("您输入的时间不正确");
        }
    }
}
